﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Xejen.Communication.Soap
{
    /// <summary>
    /// 表示服务请求地址
    /// </summary>
    /// <creator>marc</creator>
    public class SoapAddress
    {
        /// <summary>
        /// 地址
        /// </summary>
        public string RequestUri { get; set; }

        /// <summary>
        /// 方法名
        /// </summary>
        public string MethodName { get; set; }

        /// <inheritdoc cref="SoapAddress"/>
        public SoapAddress() { }

        /// <inheritdoc cref="SoapAddress"/>
        /// <param name="requestUri"><inheritdoc cref="RequestUri" path="/summary"/></param>
        /// <param name="methodName"><inheritdoc cref="MethodName" path="/summary"/></param>
        public SoapAddress(string requestUri, string methodName)
        {
            RequestUri = requestUri;
            MethodName = methodName;
        }

        /// <inheritdoc/>
        public override string ToString()
        {
            return $"{nameof(RequestUri)}:{RequestUri}\r\n{nameof(MethodName)}:{MethodName}";
        }

        /// <inheritdoc/>
        public override int GetHashCode()
        {
            return (RequestUri, MethodName).GetHashCode();
        }

        /// <inheritdoc/>
        public override bool Equals(object obj)
        {
            var target = obj as SoapAddress;
            return MethodName == target.MethodName && RequestUri.ToLower() == target.RequestUri.ToLower();
        }
    }
}
